/**
 * UploadPictureForm.java
 *
 *
 * $LastChangedBy: allen $
 * $LastChangedDate: 2007-12-04 19:48:33 +0800 $
 * $Revision: 1357 $
 */
package com.myspace.view.picture;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.upload.FormFile;

import com.myspace.view.common.Constant;

public class UploadPictureForm extends ActionForm {

	private static final long serialVersionUID = 20071120L;

	private FormFile[] imageFiles = new FormFile[Constant.UPLOAD_FILE_SIZE];

	private String[] imageNames = new String[Constant.UPLOAD_FILE_SIZE];

	private String[] imageTags = new String[Constant.UPLOAD_FILE_SIZE];

	private String tag = "";

	private String date = "";

	private long userId = -1;

	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public FormFile getImageFile(int index) {
		return imageFiles[index];
	}

	public void setImageFile(int index, FormFile imageFile) {
		this.imageFiles[index] = imageFile;
	}

	public String getImageName(int index) {
		return imageNames[index];
	}

	public void setImageName(int index, String imageName) {
		this.imageNames[index] = imageName;
	}

	public String getImageTag(int index) {
		return imageTags[index];
	}

	public void setImageTag(int index, String imageTag) {
		this.imageTags[index] = imageTag;
	}

	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		for (int i = 0; i < imageFiles.length; i++) {
			if (imageFiles[i] != null
					&& imageFiles[i].getFileSize() > Constant.PIC_FILE_LIMIT) {
				errors.add("imageFile[" + i + "]", new ActionMessage(
						"Picture is over 5MB!", false));
			}
		}
		return errors;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

}
